//
//  LGConsultationVideoCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/23.
//

#import "LGConsultationVideoCell.h"

@interface LGConsultationVideoCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)CAGradientLayer *gradientLayer;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UIView *lineView;
/**   */
@property (nonatomic , strong)UIImageView *iconView;
/**   */
@property (nonatomic , strong)UIView *bottomView;
/**   */
@property (nonatomic , strong)UILabel *appointTime;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;
/**   */
@property (nonatomic , strong)UIButton *touchBtn;
/**   */
@property (nonatomic , copy)NSString *appointId;

@end

@implementation LGConsultationVideoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)fillWithData:(LGCustomCellData *)data{
    [super fillWithData:data];
    self.appointId = LGNSString(data.customDic[@"bus_id"]);
    NSDictionary *patientDic = data.customDic[@"msgcontent_doctor"];
    self.titleLabel.text = LGNSString(patientDic[@"title"]);
    self.appointTime.text = LGNSString(patientDic[@"content"]);
    self.contentLabel.text = LGNSString(patientDic[@"desc"]);
}

-(void)checkOrderDetailAction{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"CheckOrderDetail" object:nil userInfo:@{@"appointId":self.appointId}];
}

-(void)layoutSubviews{
    [super layoutSubviews];
    CGFloat height = self.container.size.height;
    self.baseView.frame = CGRectMake(0, 0, Screen_W-viewPix(100), height);
    self.gradientLayer.frame = CGRectMake(0, 0, Screen_W-viewPix(100), height);
}
#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.container addSubview:self.baseView];
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.lineView];
    [self.baseView addSubview:self.bottomView];
    [self.bottomView addSubview:self.iconView];
    [self.bottomView addSubview:self.appointTime];
    [self.bottomView addSubview:self.contentLabel];
    [self.baseView addSubview:self.touchBtn];
    
    [self.appointTime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(viewPix(7));
        make.centerY.equalTo(self.iconView);
        make.right.equalTo(self.bottomView).offset(-viewPix(5));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.appointTime.mas_bottom).offset(7);
        make.left.right.equalTo(self.appointTime);
    }];
    [self.touchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.top.equalTo(self.baseView);
    }];
}
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] init];
        _baseView.backgroundColor = [UIColor whiteColor];
        _baseView.cornerRidus = 10;
    }
    return _baseView;
}


-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _titleLabel.frame = CGRectMake(viewPix(12), viewPix(9), Screen_W-viewPix(124), viewPix(22));
    }
    return _titleLabel;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(12), viewPix(40), Screen_W-viewPix(124), 0.5)];
        _lineView.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView;
}

-(UIView *)bottomView{
    if(!_bottomView){
        _bottomView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(12), kMaxY(self.lineView.frame)+viewPix(8), Screen_W-viewPix(120), viewPix(54))];
        _bottomView.backgroundColor = [UIColor colorWithString:@"#F7F9FB"];
    }
    return _bottomView;
}


-(UIImageView *)iconView{
    if(!_iconView){
        _iconView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"聊天咨询-推荐视频"]];
        _iconView.frame = CGRectMake(viewPix(6), viewPix(9), viewPix(35), viewPix(15));
    }
    return _iconView;
}

-(UILabel *)appointTime{
    if(!_appointTime){
        _appointTime = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _appointTime;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _contentLabel;
}

-(UIButton *)touchBtn{
    if(!_touchBtn){
        _touchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_touchBtn addTarget:self action:@selector(checkOrderDetailAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _touchBtn;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
